/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
 *
 */

import { TargetTaskCreator, TaskCreatorManager } from '../../../tasks/task-creator.js';
import { TaskNames } from '../../../tasks/common/task-names.js';
import { CompileArktsEvolution } from '../compile-arkts-evolution.js';
import { CoreTask, TaskDetails } from '@ohos/hvigor';
import { TargetTaskService } from '../../../tasks/service/target-task-service.js';
import { CompileResource } from '../../../tasks/compile-resource.js';
import { GenerateLoaderJson } from '../../../tasks/generate-loader-json.js';
import { OhosTestCompileArktsEvolution } from '../ohos-test-compile-arkts-evolution.js';

export const initializeArkTsV2Tasks = (service: TargetTaskService, creatorManager: TaskCreatorManager) => {
  // ArkTS1.2 compile
  creatorManager.registry(new ArkTSEvolutionCA(service));
  creatorManager.registry(new OhosTestArkTSEvolutionCA(service));
};

export class ArkTSEvolutionCA extends TargetTaskCreator {
  provider = (): CoreTask => new CompileArktsEvolution(this.targetService, TaskNames.Task.COMPILE_ARKTS_EVOLUTION);

  declareTaskDetail = (): TaskDetails => TaskNames.Task.COMPILE_ARKTS_EVOLUTION;

  declareDepends = () => {
    const depends = [GenerateLoaderJson.name, CompileResource.name, TaskNames.Task.CACHE_NATIVE_LIBS.name];
    return depends;
  };
}

export class OhosTestArkTSEvolutionCA extends TargetTaskCreator {
  provider = (): CoreTask => new OhosTestCompileArktsEvolution(this.targetService, TaskNames.Task.OHOS_TEST_COMPILE_ARKTS_EVOLUTION);

  declareTaskDetail = (): TaskDetails => TaskNames.Task.OHOS_TEST_COMPILE_ARKTS_EVOLUTION;

  declareDepends = () => {
    const depends = [GenerateLoaderJson.name, CompileResource.name, TaskNames.Task.CACHE_NATIVE_LIBS.name];
    return depends;
  };
}
